import { eLayoutType, RoutesService } from '@abp/ng.core';
import { APP_INITIALIZER } from '@angular/core';
import { eAccountRouteNames } from '@abp/ng.account/config';
import { eRoutePaths } from '../enums';

export const ACCOUNT_ROUTE_PROVIDERS = [
  { provide: APP_INITIALIZER, useFactory: configureRoutes, deps: [RoutesService], multi: true },
];

export function configureRoutes(routes: RoutesService) {
  return () => {
    routes.remove([eAccountRouteNames.Account]);
    routes.add([
      {
        path: `/${eRoutePaths.Account}/login`,
        name: `/${eRoutePaths.Account}/login`,
        layout: eLayoutType.empty,
        invisible: true,
      },
    ]);
  };
}
